package com.dxy.lc.controller;

import com.dxy.lc.model.bean.RoomEditDto;
import com.dxy.lc.model.entity.RoomUser;
import com.dxy.lc.model.entity.User;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.PostMapping;
import com.dxy.lc.base.Resp;
import java.util.List;
import com.dxy.lc.model.entity.Room;
import com.dxy.lc.service.RoomService;

/**
* <p>
*  controller
* </p>
*
* @author dxy
* @since 2024-11-07
*/
@Slf4j
@RestController
@RequestMapping("/lc/room")
public class RoomController {

    @Autowired
    private RoomService service;

    @PostMapping("/updById")
    public Resp updById(@RequestBody RoomEditDto param) {
        service.updById(param);
        return Resp.bizSuccess();
    }

    @GetMapping("/getDetail")
    public Resp<Room> getDetail(Integer id){
        return Resp.bizSuccess(service.getDetail(id));
    }

    @GetMapping("/getList")
    public Resp<List<Room>> getList(String kw){
        return Resp.bizSuccess(service.getList(kw));
    }

    @PostMapping("/createRoom")
    public Resp<Room> createRoom(@RequestBody List<Integer> toUserIds){
        return Resp.bizSuccess(service.createRoom(toUserIds));
    }

    @PostMapping("/addMember")
    public Resp addMember(@RequestBody RoomEditDto param){
        service.addMember(param);
        return Resp.bizSuccess();
    }

    @PostMapping("/quitRoom")
    public Resp quitRoom(@RequestBody RoomEditDto param){
        service.quitRoom(param);
        return Resp.bizSuccess();
    }

    @PostMapping("/setMuted")
    public Resp setMuted(@RequestBody RoomUser param){
        service.setMuted(param);
        return Resp.bizSuccess();
    }

    @GetMapping("/getUsers")
    public Resp<List<User>> getUsers(Integer roomId){
        return Resp.bizSuccess(service.getUsers(roomId));
    }
}